//
//  RFATree.h
//  RFA Manager
//
//  Created by Torsten Kammer on 23.02.08.
//  Copyright 2008 Ferroequinologist.de. All rights reserved.
//

#import <Cocoa/Cocoa.h>

@interface RFATreeNode : NSObject <NSCopying>
{
	RFATreeNode *parent;

    NSMutableArray *children;
    NSData *data;
    NSString *name;
	
	NSImage *image;
	
	NSUndoManager *undoManager;
}

+ (RFATreeNode *)nodeFromFile:(NSString *)file parent:(RFATreeNode *)node;

- (id)copyWithZone:(NSZone *)zone;

- (id)initAsDirectory:(NSString *)directory;
- (id)initAsDirectory:(NSString *)directory parent:(RFATreeNode *)node;
- (void)addFileWithData:(NSData *)data atPath:(NSString *)path;
- (void)addFileWithData:(NSData *)data atPathArray:(NSArray *)path;

- (NSArray *)nodesMatchingPredicate:(NSPredicate *)predicate;

@property (readonly) BOOL isImage;
@property (readonly) BOOL isText;

- (NSUInteger)countOfChildren;
- (RFATreeNode *)objectInChildrenAtIndex:(NSUInteger)index;
- (void)insertObject:(RFATreeNode *)node inChildrenAtIndex:(NSUInteger)index;
- (void)removeObjectFromChildrenAtIndex:(NSUInteger)index;
- (void)removeChildNamed:(NSString *)name;

- (RFATreeNode *)childWithName:(NSString *)name;
- (RFATreeNode *)childWithPathArray:(NSArray *)pathArray;
- (BOOL)hasChildWithName:(NSString *)name isDirectory:(BOOL *)isDir;

@property (readonly) BOOL isLeaf;

@property (readonly) NSArray *flattenedTree;

@property (copy) NSString *name;

@property (copy) NSData *data;

@property (readonly) NSUInteger fullSize;

@property (assign) NSString *contents;
@property (readonly) NSImage *image;

@property (assign) RFATreeNode *parent;
@property (readonly) NSString *fullPath;

- (NSEnumerator *)leafEnumerator;

@property (readonly) NSUInteger leafCount;

@property (assign) NSUndoManager *undoManager;

- (BOOL)isDescendantOf:(RFATreeNode *)node;

- (NSFileWrapper *)fileWrapper;

@end
